package main

import "fmt"

func main() {

	definedArr()
}

func definedArr() {
	var intArr [3]int

	//for i ,item :=range &intArr{
	//	fmt.Println(i,item)
	//	item=rand.Int()
	//	fmt.Println("结果：",i,intArr[i])
	//}
	//
	// for i,item:=range  intArr{
	//	fmt.Println(i,item)
	//}

	//数组的定义方式
	var intArr1 = [...]int{1, 2, 3, 4}
	var intArr2 = [...]int{1, 2, 2: 4}
	var intArr3 = [...]int{1, 2, 3, 5: 6, 8, 10}
	fmt.Printf("intArr: %#v\n", intArr)
	fmt.Printf("intArr1: %#v\n", intArr1)
	fmt.Printf("intArr2: %#v\n", intArr2)
	fmt.Printf("intArr3: %#v\n", intArr3)

	//数组的遍历方式
	//for i := range intArr1 {
	//	fmt.Println(i, ":", intArr[i], "--")
	//}
	for i, item := range intArr1 {
		//item = 2;
		fmt.Println(i, ":", item, "--", &item)
	}
	for i, item := range intArr1 {
		item = 2
		//intArr1[i] = 2
		fmt.Println(i, ":", item, "--", &intArr1[i])
	}

	//通过指针的方式进行遍历
	var intArr1Point = &intArr1

	for i := range intArr1Point {
		fmt.Println(i, ":", (*intArr1Point)[i], "--", &intArr1[0])
	}
	for i, item := range intArr1Point {
		item = 2
		fmt.Println(i, ":", item, "--", &intArr1[0])
	}
	for i, item := range intArr1Point {
		item = 2
		intArr1[i] = 2
		fmt.Println(i, ":", item, "--", &intArr1[i])
	}
}
